package com.example.mapper;

import com.example.entity.CampusResource;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CampusResourceMapper {

    @Insert("INSERT INTO campus_resources (resource_name, phone_number, location, open_hours, resource_type) " +
            "VALUES (#{resourceName}, #{phoneNumber}, #{location}, #{openHours}, #{resourceType})")
    int insertCampusResource(CampusResource resource);

    @Delete("DELETE FROM campus_resources WHERE resource_id = #{resourceId}")
    int deleteCampusResourceById(Integer resourceId);

    @Update("UPDATE campus_resources SET resource_name = #{resourceName}, phone_number = #{phoneNumber}, " +
            "location = #{location}, open_hours = #{openHours}, resource_type = #{resourceType} " +
            "WHERE resource_id = #{resourceId}")
    int updateCampusResource(CampusResource resource);

    @Select("SELECT * FROM campus_resources")
    List<CampusResource> getAllCampusResources();
}
